package fr.esiag.isidis.pdsTeam.Gateway_Mock;

public class RawInformationParcer {

	private String parcedInformation;
	
	public enum Source {
		Train, Station, Tunel;
	}
	
	public enum Train {
		ZUCO, ROVO, HUGO, RIVO, MIMI, LALA;
	}
	
	public enum Station {
		La_defense, Gare_de_lyon, Auber,Point_du_lac ,Chatelet_les_halles ;
	}
	
	public enum Alerte {
		Position,Feu, Haute_temp, Homme_sur_rails;
	}
	
	public RawInformationParcer() {
		
	}
	
	void Parce(byte b1, byte b2){
		
		
		byte tmpb1=b1;
		tmpb1=(byte)(tmpb1>>4);
		int typeSource=tmpb1;
		tmpb1=b1;
		int n=Integer.toBinaryString(tmpb1).length();
		tmpb1=(byte)(tmpb1<<4);
		tmpb1=(byte)(tmpb1>>4);
		int idSource=tmpb1;
		
		
		byte tmpb2=b2;
		tmpb2=(byte)(tmpb2>>4);
		int codeInformation=tmpb2;
		tmpb2=b2;
		n=Integer.toBinaryString(tmpb2).length();
		tmpb2=(byte)(tmpb2<<4);
		tmpb2=(byte)(tmpb2>>4);
		int alert=tmpb2;
		
		afficherInformation(typeSource,idSource,codeInformation,alert);
	}
	
	
	void afficherInformation(int typeSource,int idSource,int codeInformation,int alert){
		String typeS="";
		String res="";
		switch (typeSource) {
		case 0 :
			 	typeS=Source.Train.toString();
			 	res="Le train "+getNomTrain(idSource)+" est dans la station "+getNomStation(codeInformation);
			 	if(alert==0)
			 		res="[Position]"+res;
			 	if(alert==1)
			 		res="[Alert:Feu]"+res;
			 	parcedInformation=res;
			 	break;
		
		case 1 :
			//
			 break;
			 
		case 2 :
			//
			 break;
		}
		
	}
	
	
		String getNomTrain(int train){
			String nomTrain="";
			switch (train) {

			case 0 :
				 	nomTrain=Train.ZUCO.toString();
				 	break;
			
			case 1 :
				nomTrain=Train.ROVO.toString();
			 	break; 
			case 2 :
				nomTrain=Train.HUGO.toString();
			 	break;
			case 3 :
				nomTrain=Train.RIVO.toString();
			 	break;
			}
			return nomTrain;
		}
		
		String getNomStation(int station){
			String nomStation="";
			switch (station) {

			case 0 :
				nomStation=Station.La_defense.toString();
				 	break;
			
			case 1 :
				nomStation=Station.Gare_de_lyon.toString();
			 	break; 
			case 2 :
				nomStation=Station.Auber.toString();
			 	break;
			case 3 :
				nomStation=Station.Point_du_lac.toString();
			 	break;
			case 4 :
				nomStation=Station.Chatelet_les_halles.toString();
			 	break;
			}
			return nomStation;
		}

		public String getParcedInformation() {
			return parcedInformation;
		}

		public void setParcedInformation(String parcedInformation) {
			this.parcedInformation = parcedInformation;
		}
}
